<?php

declare(strict_types=1);
/**
 * Author: Zane
 * Email: 873934580@qq.com
 * Date: 2022/4/8.
 */

namespace Zane\TableHandle\Components;

use Zane\TableHandle\Base;

class Datetime extends Base
{
    protected $fieldType = 'bigInteger';

    public function getRules(): array
    {
        return [];
    }

    public function getSaveVal($val, $param)
    {
        if ($val) {
            return dateToTime($val);
        }

        return 0;
    }

    public function getVal($val, $param)
    {
        if ($val) {
            return date('Y-m-d H:i:s', $val);
        }

        return '';
    }

    protected function isUnsigned(): bool
    {
        return true;
    }
}
